<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model="value">
        <p>姓：{{xing}}</p>
        <p>名：{{ming}}</p>
    </div>
    <script src="../vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            data () {
                return {
                    text:'hello',
                    value:'',
                    ary:[
                        '欧阳','上官','李杜'
                    ],
                }
            },
            computed: {
                //有缓存 所以存在错误
                xing(){
                    let len=this.ary.length;
                    for(let i=0;i<len;i++){
                        if(this.value.substr(0,2)==this.ary[i]){
                            return this.value.substr('',2);
                        }
                        else{
                            return this.value.substr('',1);
                        }
                    }
                },
                ming(){
                    let len=this.ary.length;
                    for(let i=0;i<len;i++){
                        if(this.value.substr(0,2)==this.ary[i]){
                            return this.value.substr(2);
                        }
                        else{
                            return this.value.substr(1);
                        }
                    }
                }
            }
        })
    </script>
</body>
</html>